﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GNSCore.Model;
using GNSCore.Model.Context;
using Microsoft.Practices.Unity;

namespace GNSCore.Repositories.IOC
{
    /// <summary>
    /// For configuring ioc container
    /// </summary>
    public class IOCManager
    {
        public static IUnityContainer IOCContainer { get; set; }

        /// <summary>
        /// Configures all associations between types
        /// </summary>
        public static void ConfigureContainer(IGNSContext context)
        {
            IOCContainer = new UnityContainer();
            IOCContainer.RegisterInstance<IGNSContext>(context);
            IOCContainer.RegisterType<IRepository<UserSettings>, Repository<UserSettings>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<User>, Repository<User>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<Locale>, Repository<Locale>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<Location>, Repository<Location>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<Membership>, Repository<Membership>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<GeoData>, Repository<GeoData>>(new ContainerControlledLifetimeManager());
            IOCContainer.RegisterType<IRepository<GeoExtensionData>, Repository<GeoExtensionData>>(new ContainerControlledLifetimeManager());
        }
    }
}